TextOutputStream Class
In order to write text to a file, you need to create a TextOutputStream object. TextOutputStreams have methods that allow to write to a file and close the file when you are done writing to it.
More information available in parent classes: Object
They are created by calling the CreateTextFile and AppendToTextFile methods of a FolderItem object. If you need to specify the encoding of the text, call ConvertEncoding prior to writing the file.
Notes
The TextOutputStream class implements the Writeable class interface. If you implement this interface, you must provide the methods with the parameters as specified by the class interface.
For more information about class interfaces and how to implement them, see the section "Class Interfaces" in the User's Guide.
If you need to write the file using a particular encoding, use the ConvertEncoding function to first convert the encoding of the text to the desired encoding before passing the text to the Write or WriteLine methods. Here is an example:
Dim t as TextOutputStream
f = GetFolderItem("Sample.txt")
t = f.CreateTextFile
t.Write ConvertEncoding(Editfield1.text, Encodings.WindowsANSI)
t.close
Example
This example displays the Save As dialog box. A text file is then created and the text properties of three EditFields are written to the new file. Finally the file is closed.
Dim fileStream As TextOutputStream
file= GetSaveFolderItem("application/text","My Info")
fileStream=file.CreateTextFile
fileStream.WriteLine namefield.text
fileStream.WriteLine addressfield.text
fileStream.WriteLine phonefield.text
fileStream.Close
See Also
BinaryStream, FolderItem, TextInputStream classes; ConvertEncoding function; Encodings object; Writeable class interface.